package hawk.example.bookstore.po;

import static glz.hawkframework.support.ArgumentSupport.*;

import glz.hawkframework.dao.base.function.ColumnDescriptor;
import glz.hawkframework.dao.base.function.ColumnFunction;
import glz.hawkframework.dao.base.function.IRecord;
import glz.hawkframework.dao.base.function.RecordCreateDateTimeFunction;
import glz.hawkframework.dao.base.function.RecordCreateUserIdFunction;
import glz.hawkframework.dao.base.function.RecordIdFunction;
import glz.hawkframework.dao.base.function.RecordUpdateDateTimeFunction;
import glz.hawkframework.dao.base.function.RecordUpdateUserIdFunction;
import glz.hawkframework.dao.base.function.RecordVersionFunction;

import java.math.BigInteger;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

/**
 * Map to table: BOOK_INVENTORY
 */
public class BookInventoryPo implements IRecord {
    /**
     * Map to column: BOOK_INVENTORY_ID
     */
    private BigInteger bookInventoryId;
    /**
     * Map to column: BOOK_ID
     */
    private BigInteger bookId;
    /**
     * 指定存储位置的数量
     * <p>Map to column: BOOK_QUANTITY</p>
     */
    private Integer bookQuantity;
    /**
     * 存储位置编号
     * <p>Map to column: LOCATION_CODE</p>
     */
    private String locationCode;
    /**
     * Map to column: CREATE_DATE_TIME
     */
    private LocalDateTime createDateTime;
    /**
     * Map to column: UPDATE_DATE_TIME
     */
    private LocalDateTime updateDateTime;
    /**
     * Map to column: DELETE_DATE_TIME
     */
    private LocalDateTime deleteDateTime;
    /**
     * Map to column: CREATE_USER_ID
     */
    private String createUserId;
    /**
     * Map to column: UPDATE_USER_ID
     */
    private String updateUserId;
    /**
     * Map to column: DELETE_USER_ID
     */
    private String deleteUserId;
    /**
     * Map to column: RECORD_VERSION
     */
    private Long recordVersion;
    /**
     * This map holds the relations between function class and column
     */
    private final Map<Class<? extends ColumnFunction>, ColumnDescriptor<?>> functionMap = new HashMap<>();

    {
        functionMap.put(RecordIdFunction.class, new ColumnDescriptor<>("BOOK_INVENTORY_ID", "bookInventoryId", this::getBookInventoryId, null, this::setBookInventoryId));
        functionMap.put(RecordCreateDateTimeFunction.class, new ColumnDescriptor<>("CREATE_DATE_TIME", "createDateTime", this::getCreateDateTime, null, this::setCreateDateTime));
        functionMap.put(RecordUpdateDateTimeFunction.class, new ColumnDescriptor<>("UPDATE_DATE_TIME", "updateDateTime", this::getUpdateDateTime, null, this::setUpdateDateTime));
        functionMap.put(RecordCreateUserIdFunction.class, new ColumnDescriptor<>("CREATE_USER_ID", "createUserId", this::getCreateUserId, null, this::setCreateUserId));
        functionMap.put(RecordUpdateUserIdFunction.class, new ColumnDescriptor<>("UPDATE_USER_ID", "updateUserId", this::getUpdateUserId, null, this::setUpdateUserId));
        functionMap.put(RecordVersionFunction.class, new ColumnDescriptor<>("RECORD_VERSION", "recordVersion", this::getRecordVersion, null, this::setRecordVersion));
    }

    /**
     * Map to column: BOOK_INVENTORY_ID
     */
    public BigInteger getBookInventoryId() {
        return bookInventoryId;
    }

    /**
     * Map to column: BOOK_INVENTORY_ID
     */
    public void setBookInventoryId(BigInteger bookInventoryId) {
        this.bookInventoryId = bookInventoryId;
    }

    /**
     * Map to column: BOOK_ID
     */
    public BigInteger getBookId() {
        return bookId;
    }

    /**
     * Map to column: BOOK_ID
     */
    public void setBookId(BigInteger bookId) {
        this.bookId = bookId;
    }

    /**
     * Gets 指定存储位置的数量
     * <p>Map to column: BOOK_QUANTITY</p>
     */
    public Integer getBookQuantity() {
        return bookQuantity;
    }

    /**
     * Sets 指定存储位置的数量
     * <p>Map to column: BOOK_QUANTITY</p>
     */
    public void setBookQuantity(Integer bookQuantity) {
        this.bookQuantity = bookQuantity;
    }

    /**
     * Gets 存储位置编号
     * <p>Map to column: LOCATION_CODE</p>
     */
    public String getLocationCode() {
        return locationCode;
    }

    /**
     * Sets 存储位置编号
     * <p>Map to column: LOCATION_CODE</p>
     */
    public void setLocationCode(String locationCode) {
        this.locationCode = locationCode;
    }

    /**
     * Map to column: CREATE_DATE_TIME
     */
    public LocalDateTime getCreateDateTime() {
        return createDateTime;
    }

    /**
     * Map to column: CREATE_DATE_TIME
     */
    public void setCreateDateTime(LocalDateTime createDateTime) {
        this.createDateTime = createDateTime;
    }

    /**
     * Map to column: UPDATE_DATE_TIME
     */
    public LocalDateTime getUpdateDateTime() {
        return updateDateTime;
    }

    /**
     * Map to column: UPDATE_DATE_TIME
     */
    public void setUpdateDateTime(LocalDateTime updateDateTime) {
        this.updateDateTime = updateDateTime;
    }

    /**
     * Map to column: DELETE_DATE_TIME
     */
    public LocalDateTime getDeleteDateTime() {
        return deleteDateTime;
    }

    /**
     * Map to column: DELETE_DATE_TIME
     */
    public void setDeleteDateTime(LocalDateTime deleteDateTime) {
        this.deleteDateTime = deleteDateTime;
    }

    /**
     * Map to column: CREATE_USER_ID
     */
    public String getCreateUserId() {
        return createUserId;
    }

    /**
     * Map to column: CREATE_USER_ID
     */
    public void setCreateUserId(String createUserId) {
        this.createUserId = createUserId;
    }

    /**
     * Map to column: UPDATE_USER_ID
     */
    public String getUpdateUserId() {
        return updateUserId;
    }

    /**
     * Map to column: UPDATE_USER_ID
     */
    public void setUpdateUserId(String updateUserId) {
        this.updateUserId = updateUserId;
    }

    /**
     * Map to column: DELETE_USER_ID
     */
    public String getDeleteUserId() {
        return deleteUserId;
    }

    /**
     * Map to column: DELETE_USER_ID
     */
    public void setDeleteUserId(String deleteUserId) {
        this.deleteUserId = deleteUserId;
    }

    /**
     * Map to column: RECORD_VERSION
     */
    public Long getRecordVersion() {
        return recordVersion;
    }

    /**
     * Map to column: RECORD_VERSION
     */
    public void setRecordVersion(Long recordVersion) {
        this.recordVersion = recordVersion;
    }

    @Override
    public Optional<ColumnDescriptor<?>> findColumnDescriptor(Class<? extends ColumnFunction> columnFunctionClass) {
        return Optional.ofNullable(functionMap.get(argNotNull(columnFunctionClass, "columnFunctionClass")));
    }
}
